package com.dingreading.cloud.admin.controller;

import com.dingreading.cloud.admin.service.SubjectLessonVideoService;
import com.dingreading.cloud.common.base.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/system/subjectLessonVideo")
@Api(tags = "学科课次视频管理")
public class SubjectLessonVideoController {


    @Resource
    private SubjectLessonVideoService subjectLessonVideoService;


    @ApiOperation(value = "获取课次的视频列表")
    @PostMapping(value = "/getList")
    public R<Object> getList(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "课次uid") @RequestParam(value = "lessonUid") String lessonUid
    ) {
        return subjectLessonVideoService.getList(lessonUid);
    }


    @ApiOperation(value = "课次添加视频")
    @PostMapping(value = "/add")
    public R<Object> add(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "课次uid") @RequestParam(value = "lessonUid") String lessonUid,
            @ApiParam(value = "视频地址") @RequestParam(value = "url") String url,
            @ApiParam(value = "视频名称") @RequestParam(value = "name") String name,
            @ApiParam(value = "视频类型(0.说课视频 1.教研视频)") @RequestParam(value = "videoType") Integer videoType
    ) {
        return subjectLessonVideoService.add(headStaffUid, headStaffName, lessonUid, url, name, videoType);
    }


    @ApiOperation(value = "更新视频的启用状态")
    @PostMapping(value = "/updateEnabled", produces = "application/json; charset=UTF-8")
    public R<Object> updateEnabled(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "视频uid") @RequestParam(value = "uid") String uid,
            @ApiParam(value = "状态 0.禁用 1.启用") @RequestParam(value = "enabled") Integer enabled
    ) {
        return subjectLessonVideoService.updateEnabled(headStaffUid, headStaffName, uid, enabled);
    }


}